/**
 */
package de.claaswilke.presents.impl;

import de.claaswilke.presents.Conflict;
import de.claaswilke.presents.PastPresent;
import de.claaswilke.presents.Person;
import de.claaswilke.presents.PresentGroup;
import de.claaswilke.presents.PresentsPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Present Group</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.claaswilke.presents.impl.PresentGroupImpl#getPersons <em>Persons</em>}</li>
 *   <li>{@link de.claaswilke.presents.impl.PresentGroupImpl#getConflicts <em>Conflicts</em>}</li>
 *   <li>{@link de.claaswilke.presents.impl.PresentGroupImpl#getPastPresents <em>Past Presents</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PresentGroupImpl extends EObjectImpl implements PresentGroup {
	/**
	 * The cached value of the '{@link #getPersons() <em>Persons</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPersons()
	 * @generated
	 * @ordered
	 */
	protected EList<Person> persons;

	/**
	 * The cached value of the '{@link #getConflicts() <em>Conflicts</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConflicts()
	 * @generated
	 * @ordered
	 */
	protected EList<Conflict> conflicts;

	/**
	 * The cached value of the '{@link #getPastPresents() <em>Past Presents</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPastPresents()
	 * @generated
	 * @ordered
	 */
	protected EList<PastPresent> pastPresents;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PresentGroupImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PresentsPackage.Literals.PRESENT_GROUP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Person> getPersons() {
		if (persons == null) {
			persons = new EObjectContainmentEList<Person>(Person.class, this, PresentsPackage.PRESENT_GROUP__PERSONS);
		}
		return persons;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Conflict> getConflicts() {
		if (conflicts == null) {
			conflicts = new EObjectContainmentEList<Conflict>(Conflict.class, this, PresentsPackage.PRESENT_GROUP__CONFLICTS);
		}
		return conflicts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<PastPresent> getPastPresents() {
		if (pastPresents == null) {
			pastPresents = new EObjectContainmentEList<PastPresent>(PastPresent.class, this, PresentsPackage.PRESENT_GROUP__PAST_PRESENTS);
		}
		return pastPresents;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case PresentsPackage.PRESENT_GROUP__PERSONS:
				return ((InternalEList<?>)getPersons()).basicRemove(otherEnd, msgs);
			case PresentsPackage.PRESENT_GROUP__CONFLICTS:
				return ((InternalEList<?>)getConflicts()).basicRemove(otherEnd, msgs);
			case PresentsPackage.PRESENT_GROUP__PAST_PRESENTS:
				return ((InternalEList<?>)getPastPresents()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PresentsPackage.PRESENT_GROUP__PERSONS:
				return getPersons();
			case PresentsPackage.PRESENT_GROUP__CONFLICTS:
				return getConflicts();
			case PresentsPackage.PRESENT_GROUP__PAST_PRESENTS:
				return getPastPresents();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PresentsPackage.PRESENT_GROUP__PERSONS:
				getPersons().clear();
				getPersons().addAll((Collection<? extends Person>)newValue);
				return;
			case PresentsPackage.PRESENT_GROUP__CONFLICTS:
				getConflicts().clear();
				getConflicts().addAll((Collection<? extends Conflict>)newValue);
				return;
			case PresentsPackage.PRESENT_GROUP__PAST_PRESENTS:
				getPastPresents().clear();
				getPastPresents().addAll((Collection<? extends PastPresent>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PresentsPackage.PRESENT_GROUP__PERSONS:
				getPersons().clear();
				return;
			case PresentsPackage.PRESENT_GROUP__CONFLICTS:
				getConflicts().clear();
				return;
			case PresentsPackage.PRESENT_GROUP__PAST_PRESENTS:
				getPastPresents().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PresentsPackage.PRESENT_GROUP__PERSONS:
				return persons != null && !persons.isEmpty();
			case PresentsPackage.PRESENT_GROUP__CONFLICTS:
				return conflicts != null && !conflicts.isEmpty();
			case PresentsPackage.PRESENT_GROUP__PAST_PRESENTS:
				return pastPresents != null && !pastPresents.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //PresentGroupImpl
